#include "Config.h"
#include "Common/Stream.h"
#include "GameClient.h"
#include "Server.h"
#include "Protocols/Protocol.h"

namespace Network {

GameClient::GameClient( int fd, TcpSlaveServer * s, int id )
	: NetworkClient( fd, s, id )
{
	
}

GameClient::~GameClient()
{

}

void GameClient::onRecv( UInt16 cmd, int len, void * buf )
{
	NetworkClient::onRecv( cmd, len, buf );
	UInt64 pid = m_PlayerId.value();
	MsgHdr hdr( len, cmd, Thread_Logic, id(), pid );
	MSGPOOL().pushMsg( hdr, buf );
}

void GameClient::onDisconnected()
{
	NetworkClient::onDisconnected();
	if ( _clientType == Client_Server )
	{
		UInt64 pid = m_PlayerId.value();
		MsgHdr hdr( 0, 0x201, Thread_Logic, id(), pid );
		MSGPOOL().pushMsg( hdr, nullptr );
	}
	else
	{
		UInt64 pid = m_PlayerId.value();
		MsgHdr hdr( 0, 0x100, Thread_Logic, id(), pid );
		MSGPOOL().pushMsg( hdr, nullptr );
	}
}

}